package indi.luckly.entity;

import com.baomidou.mybatisplus.annotation.*;
import indi.luckly.vo.TargetVo;
import lombok.Data;
import lombok.ToString;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author wangchengyuan
 * @since 2021-12-26
 */
@TableName("r_target")
@Data
@ToString
public class Target implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 标题
     */
    private String title;

    /**
     * 任务内容
     */
    private String content;

    /**
     * 开始时间
     */
    private Date beginTime;

    /**
     * 结束时间
     */
    private Date endTime;

    @TableField(fill = FieldFill.INSERT)
    private Date createDate;

    /**
     * 0-预备1-进行中2-失败3-完成
     */
    private Integer state;

    /**
     * 失败时间state==2
     */
    private Date failDate;

    /**
     * 奖励内容
     */
    private String reward;

    /**
     * 0-未奖励1-已奖励
     */
    private Integer rewardState;

    /**
     * 0-一个星期为一个周期1-从开始日推后n天为一个周期
     */
    private Integer cycleType;

    /**
     * 周期天数
     */
    private Integer cycleNum;

    public static Target buildFromVo(TargetVo vo) {
        Target target = new Target();
        BeanUtils.copyProperties(vo, target);
        return target;
    }

    public Target() {
        this.state = 0;
        this.rewardState = 0;
    }
}
